package net.wangds.program;

//import net.wangds.config.comp.SysConfComp;
//import net.wangds.config.module.Config;
import net.wangds.i18n.utils.I18nUtils;
import net.wangds.log.helper.LogHelper;
import net.wangds.spring.utils.SpringUtils;
import net.wangds.threadpool.comp.ThreadPoolComp;
//import net.wangds.utils.JsonUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
//import org.springframework.data.domain.Sort;

import java.util.List;

import static net.wangds.program.AppConstants.*;

@Configuration
@DependsOn({"springUtils","cacheManager"})
public class ProgramConfig implements InitializingBean {

    //@Autowired
    //private SysConfComp mmCmpConf;

    @Override
    public void afterPropertiesSet() {
        I18nUtils.addMessagePropertiesFile("messages_program");
        LogHelper.info(SpringUtils.getMessage("messages_program_loaded"));

        initAppConfig();

    }

    @Autowired
    ThreadPoolComp mmCmpThPool;

    private void initAppConfig() {

        new Thread(()->{

            mmCmpThPool.sleep(5000);

            //LogHelper.info("初始化应用配置-应用名称");
            //Config conf = mmCmpConf.cacheConfig(CONF_CATA_APP, CONF_CATA_APP_APP_NAME, CONF_CATA_APP_APP_NAME_VALUE);
            //LogHelper.info("应用名称:"+conf.getText());
            //List<Config> list = mmCmpConf.findByCata(CONF_CATA_APP, Sort.by(Sort.Order.desc("createTm")));
            //LogHelper.info(JsonUtils.toJsonStr(list));

        }).start();
    }


}

